import { ref, onMounted } from 'vue'
// 数据  分页加载数据  总数据量
import { adminUserApi } from '@/api/adminuserApi.js'

export const useUserList = () => {
  const data = ref([])
  const total = ref(0)

  const loadData = async (page=1,search=null,pagesize = 10) => {
    let ret = await adminUserApi(page,search,pagesize)
    if (ret.data.adminusers.length > 0) {
      data.value = ret.data.adminusers
      total.value = ret.data.total
    }
    return data.value
    //.length
  }
  onMounted(() => {
    loadData()
  })

  return [data, loadData, total]
}
